import request from '@/utils/request.js'

// 获取聊天历史记录
export function getChatHistory(params) {
  return request({
    url: '/api/chat/history',
    method: 'GET',
    params
  })
}

// 发送消息
export function sendMessage(data) {
  return request({
    url: '/api/chat/message',
    method: 'POST',
    data
  })
}

// 获取机器人回复
export function getRobotReply(message) {
  return request({
    url: '/api/chat/robot',
    method: 'POST',
    data: { message }
  })
}

// 标记消息已读
export function markMessageRead(messageId) {
  return request({
    url: `/api/chat/message/${messageId}/read`,
    method: 'PUT'
  })
}

// 获取未读消息数量
export function getUnreadCount() {
  return request({
    url: '/api/chat/unread',
    method: 'GET'
  })
}

// 导出chatApi对象
export const chatApi = {
  getChatHistory,
  sendMessage,
  getRobotReply,
  markMessageRead,
  getUnreadCount
} 